package android.FiltrosJava;

public class WhiteNoise extends PointFilter{
	protected double percNoise;
	public WhiteNoise(double percentNoise){		
		this.percNoise = percentNoise;
		if (this.percNoise > 1.0f){
			this.percNoise = percentNoise % 100;
			this.percNoise = (float) (this.percNoise /100.0f);
		}
	}
	
	public int[] computeFilter(int px, int py, int[] imageData){			
		double p = Math.random();		
		if (p <= this.percNoise){
			if ((imageData[0] == imageData[1]) && (imageData[1] == imageData[2])){
				int v = (int) (255 * Math.random());
				imageData[0] = v;
				imageData[1] = v;
				imageData[2] = v;
			}else{
				imageData[0] = (int) (255 * Math.random());
				imageData[1] = (int) (255 * Math.random());
				imageData[2] = (int) (255 * Math.random());
			}		
		}			
		return imageData;
	}

	@Override
	public int[] applyFilter(int[] pixels) {
		// TODO Auto-generated method stub
		return null;
	}
}